{extend name=".././view/create.html" /}

{block name="form"}
    <form class="layui-form layui-form-pane" lay-filter="myform">
          <div class="layui-form-item">
            <label for="ruxuenian" class="layui-form-label">
              <span class="x-red">*</span>年级
            </label>
            <div class="layui-input-block">
              <select name="ruxuenian" id="ruxuenian" lay-verify="required" class="layui-form-label" lay-filter="ruxuenian">
                <option value="">请选择年级</option>
              </select>
            </div>
          </div>
          <div class="layui-form-item">
            <label for="subject_id" class="layui-form-label">
              <span class="x-red">*</span>学科
            </label>
            <div class="layui-input-block">
              <select name="subject_id" id="subject_id" lay-verify="required" class="layui-form-label" lay-filter="subject_id">
                <option value="">请选择学科</option>
              </select>
            </div>
          </div>
          <input id="kaoshi_id" name="kaoshi_id" value="{$list.set.kaoshi_id}" type="hidden">
          <div class="layui-form-item" style="text-align: right;">
              <button  class="layui-btn" lay-filter="mysubmit" lay-submit="">
                  {$list.set.butname}
              </button>
          </div>
      </form>
{/block}

{block name="myjs"}
<script>

  layui.use(['laydate','form','cjgl'], function(){
    var form = layui.form;

    $(document).ready(function(){
        addNianji();
    });

    // 监听学校下拉菜单
    form.on('select(ruxuenian)', function (data) {
      addSubject();
    })

    // 添加年级
    function addNianji(){
      // 获取参数
      formval = form.val("myform");
      cjgl.createSelectOption('ruxuenian', formval, '/tools/kscy/grade', 'ruxuenian', 'nianjiname');
    }

    // 添加学校
    function addSubject(){
      // 获取参数
      formval = form.val("myform");
      cjgl.createSelectOption('subject_id', formval, '/tools/kscy/subject', 'id', 'title');
    }

  });
</script>
{/block}

